from fastapi import Request, status
from fastapi.responses import JSONResponse
from starlette.exceptions import HTTPException
 
 
async def httpExceptionHandler(request: Request, exc: HTTPException) -> JSONResponse:
    """自定义处理HTTPException"""
    return JSONResponse(
            content={"code": exc.status_code, "message": exc.detail},
            status_code=status.HTTP_200_OK,
        )